
const mysql = require('../db/mysql')
const overviewDao = require('../sql/overviewDao')


exports.overview = async (req, res)=>{
    try {
        let row = await mysql(overviewDao.selectOne)
        res.success({
            text: row[0].text,
            id: row[0].id
        })
    }catch (e) {
        console.log(e)
        res.status(500).fail('服务器错误')
    }
}

exports.update = async (req, res)=>{
    try {
        let body = {};
        if(req.body.text)body.text = req.body.text;
        // if(req.body.img_url)body.img_url = req.body.img_url;
        // if(req.body.title)body.title = req.body.title;
        let row = await mysql(overviewDao.update, [body, req.body.id]);
        if(row.affectedRows==1) return res.success({}, '修改成功！');
        else return res.fail('修改失败');
    }catch (e) {
        console.log(e)
        res.status(500).fail('服务器错误')
    }
}
